package zhongbo.java.air.airmonitor.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import zhongbo.java.air.airmonitor.listener.RedisLogSubscribeLogChanelListener;

@Configuration
@Slf4j
public class RedisListenerConfig {

    public static String LIVE_FLIGHT_PATH_ZHU = "live_flight_path_zhu";
    @Autowired
    public void configListener(RedisMessageListenerContainer listenerContainer,
                               RedisLogSubscribeLogChanelListener logChanelListener){
        log.info("配置redis监听层");
        // 配置 RedisLogSubscribeListener 监听频道 LIVE_FLIGHT_PATH_ZHU 接收消息
        Topic topic = new PatternTopic(LIVE_FLIGHT_PATH_ZHU);
        listenerContainer.addMessageListener(logChanelListener,topic);
    }
}
